package com.chukun.spring.beans.defination;


import com.chunkun.ioc.domain.User;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 通过别名查找bean
 * @author chukun
 */
public class BeanAliasDemo {

    public static void main(String[] args) {

        BeanFactory beanFactory = new ClassPathXmlApplicationContext("classpath:/META-INF/bean-definitions-context.xml");

        // 根据别名查找bean
        User aliasUser = beanFactory.getBean("chukun-user", User.class);
        // 根据id查找bean
        User user = beanFactory.getBean("user", User.class);

        System.out.println("aliasUser == user   "+ (aliasUser == user) );
    }
}
